package com.example.demo.controller;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @program: demo
 * @author: JCM
 * @create: 2023-06-13 15:46
 * @description:
 **/
@RestController // RestController 返回数据，不返回页面
@RequestMapping("/user")
public class UserController {

//    @GetMapping
//    public String getMethod() {
//        return "执行了 getMethod";
//    }
//
//    @PostMapping
//    public String postMethod() {
//        return "执行了 postMethod";
//    }

    @RequestMapping("/getUser")
    public String getUser() {
        return "执行了 getUser";
    }

    @RequestMapping("/login")
    public String login() {
        Object obj = null;
        obj.hashCode();
        System.out.println("执行了 login");
        return "执行了 login";
    }
    @RequestMapping("/reg")
    public String reg() {
//        int num = 10/0;
        System.out.println("执行了 reg");
        return "执行了 reg";
    }

    @RequestMapping("/getNum")
    public Integer getNum() {
        int n = new Random().nextInt(10);
        System.out.println(n);
        return n;
    }
}
